package com.hp.ppm.ext.service;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hp.ppm.ext.kuka.LoginCheck;

@WebServlet(urlPatterns = "/uc")
public class LoginService extends HttpServlet {
	
	private LoginCheck logincheck;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String username=req.getParameter("mname");
		String mpwd=req.getParameter("mpwd");
		resp.setContentType("application/json; charset=utf-8"); 
		resp.getOutputStream().write(logincheck.checkUser(username, mpwd).getBytes("UTF-8"));
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
	
	@Override
	public void destroy() {
		logincheck=null;
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		logincheck=new LoginCheck();
		super.init();
	}
	
	

}
	